# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Union
from fastapi import Query
from pydantic import BaseModel, Field


class FilesSearchIn(BaseModel):
    """ 文档搜索参数 """
    keyword: Union[str, None] = Query(default=None, max_length=200, description="关键词")


class FilesDetailIn(BaseModel):
    """ 文档详情参数 """
    code: str = Query(..., min_length=1, max_length=32, description="文档编号")


class FilesRenameIn(BaseModel):
    """ 文档命名参数 """
    code: str = Field(..., min_length=1, max_length=32, description="文档编号")
    name: str = Field(..., min_length=1, max_length=200, description="文档名称")

    class Config:
        json_schema_extra = {
            "example": {
                "code": "698d51a19d8a121ce581499d7b701668",
                "name": "ojbk.pdf"
            }
        }


class FilesDeleteIn(BaseModel):
    """ 文档删除参数 """
    code: str = Field(..., min_length=1, max_length=32, description="文档编号")

    class Config:
        json_schema_extra = {
            "example": {
                "code": "698d51a19d8a121ce581499d7b701668"
            }
        }


class FilesDialogSendIn(BaseModel):
    """ 发起对话参数 """
    type: str = Field(default="chat", pattern=r"^(dialogue|abstract|translate|mind)$", description="来源场景")
    code: str = Field(..., max_length=32, description="文档编号")
    question: str = Field(default="", description="提问问题")

    class Config:
        json_schema_extra = {
            "example": {
                "type": "dialogue",
                "code": "698d51a19d8a121ce581499d7b701668",
                "question": "Hello"
            }
        }


"""--------------- Separator ---------------"""


class FilesPromptsVo(BaseModel):
    """ 文件模式Vo """
    code: str = Field(description="模式编号")
    icon: str = Field(description="模式图标")
    name: str = Field(description="模式名称")
    intro: str = Field(description="模式简介")

    class Config:
        json_schema_extra = {
            "example": {
                "code": "06870664",
                "icon": "https://www.wa.com/storage/img/wa.png",
                "name": "Construction",
                "intro": "this is intro"
            }
        }


class FilesListVo(BaseModel):
    """ 文件列表Vo """
    code: str = Field(description="文件编号")
    name: str = Field(description="文件名称")
    path: str = Field(description="文件路径")
    size: int = Field(description="文件大小")
    create_time: str = Field(description="上传时间")

    class Config:
        json_schema_extra = {
            "example": {
                "code": "698d51a19d8a121ce581499d7b701668",
                "name": "Construction.docx",
                "path": "https://www.wa.com/storage/files/wuqi.docx",
                "size": 1560,
                "create_time": "2024-11-02 20:34:18"
            }
        }


class FilesDetailVo(BaseModel):
    """ 文件详情Vo """
    code: str = Field(description="文件编号")
    name: str = Field(description="文件名称")
    path: str = Field(description="文件路径")
    size: int = Field(description="文件大小")
    error: str = Field(description="失败原因")
    status: int = Field(description="训练状态: [0=待训练, 1=训练中, 2=训练成功, 3=训练失败]")
    auto_abstract: int = Field(description="自动总结: [0=否, 1=是]")
    chat_avatar: str = Field(description="对话头像")
    prompt_icon: str = Field(description="模式图标")
    prompt_name: str = Field(description="模式名称")
    prompt_intro: str = Field(description="模式简介")
    create_time: str = Field(description="上传时间")
    abstract: str = Field(description="摘要内容")
    translate: str = Field(description="翻译内容")

    class Config:
        json_schema_extra = {
            "example": {
                "code": "698d51a19d8a121ce581499d7b701668",
                "name": "Construction.docx",
                "path": "https://www.wa.com/storage/files/wuqi.docx",
                "size": 1560,
                "error": "",
                "status": 0,
                "auto_abstract": 0,
                "chat_avatar": "https://www.wa.com/storage/img/avatar.png",
                "prompt_icon": "https://www.wa.com/storage/img/wuqi.png",
                "prompt_name": "this is prompt name",
                "prompt_intro": "this is prompt intro",
                "abstract": "this is abstract",
                "translate": "this is translate",
                "create_time": "2024-11-02 20:34:18"
            }
        }


class FilesUploadVo(BaseModel):
    """ 文件上传Vo """
    code: str = Field(description="文件编号")
    name: str = Field(description="文件名称")
    path: str = Field(description="文件路径")
    size: int = Field(description="文件大小")
    ext: str = Field(description="文件扩展")

    class Config:
        json_schema_extra = {
            "example": {
                "code": "698d51a19d8a121ce581499d7b701668",
                "name": "Construction.docx",
                "path": "https://www.wa.com/storage/files/wuqi.docx",
                "size": 1560,
                "ext": "docx"
            }
        }

